﻿using Glue;
using Xunit;

namespace GlueExamples
{
    public class Methods
    {
        private readonly Mapping<DomainPerson, GuiPerson> mapping;

        private class GuiPerson
        {
            public int Id { get; set; }
        }

        private class DomainPerson
        {
            public int GetId() 
            {
                return 3;
            }
        }

        public Methods()
        {
            mapping = new Mapping<DomainPerson, GuiPerson>();
        }

        [Fact]
        public void Should_allow_relations_away_from_methods()
        {
            mapping.RelateTowardsRight(domain => domain.GetId(), gui => gui.Id);
        }

        [Fact]
        public void Should_not_allow_relations_towards_methods()
        {
            
            Assert.Throws<GlueException>(() =>
                mapping.RelateTowardsLeft(domain => domain.GetId(), gui => gui.Id)
            );
        }

        [Fact]
        public void Should_not_fail_verification_on_methods()
        {
            mapping.GetRelationsVerification().AssertAllPropertiesRelated<DomainPerson>();
        }
    }
}
